from flask import session, make_response, current_app
from ExtendRegister.db_register import db
from ExtendRegister.model_register import User, ApiLog
from .entity import VipLogListModel, ApiLogListModel
from common import Result, PageNav
import logging
import math
from datetime import datetime,timedelta

LOGGER = logging.getLogger(__name__)


class UserService:

    def get_user_info(self, uid: int) -> Result:
        try:
            user = User()
            user.id = 1
            user.username = "OpenEssay"
            user.headimg = ""
            user.vip_start_at = datetime.now() + timedelta(days=365)
            user.vip_expire_at = datetime.now() - timedelta(days=1)
            if user is None:
                return Result().error("用户不存在")
            return Result().setData(user.get_info())
        except Exception as e:
            LOGGER.exception(e)
            return Result().error(e)

